package com.ajk.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ajk.server.dao.provider.BodypartDictProvider;
import com.ajk.server.model.BodypartDict;
import com.ajk.server.model.query.BodypartDictQuery;
import com.ajk.server.model.response.BodypartDictRes;
/**
 * 身体部位  <br>
 * dict_bodypart <br>
 * v1.0 2016-05-01
 */
import com.ajk.server.model.response.SymptomRes;
 public interface BodypartDictMapper {
 	
 	/**
 	*根据id删除 身体部位
 	*/
 	@Delete("delete from dict_bodypart where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	/**
 	* 批量新增 身体部位
 	*/
 	@InsertProvider(method="batchInsert",type=BodypartDictProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends BodypartDict> bodypartDicts);
 	
 	/**
 	* 新增 身体部位
 	*/
 	@InsertProvider(method="insert",type=BodypartDictProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(BodypartDict domain);
 
 	
 	/**
 	*更新 身体部位
 	*/
 	@UpdateProvider(method="update",type=BodypartDictProvider.class)
 	public Integer update(BodypartDict domain);
 	
 	/**
 	*根据ID查询 身体部位
 	*/
	@Select("select * from dict_bodypart where id=#{id}")
	public BodypartDict findById(Integer id);
	
	/**
 	*通过query 查询 身体部位
 	*/
 	@SelectProvider(method="findByQuery",type=BodypartDictProvider.class)
 	public List<BodypartDictRes> findByQuery(BodypartDictQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=BodypartDictProvider.class)
 	public Integer countByQuery(BodypartDictQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=BodypartDictProvider.class)
 	public List<BodypartDict> findByIds(List<Integer> ids);
 	
 	 /**
 	*根据name查询 身体部位
 	*/
	@Select("select * from dict_bodypart where name=#{name} limit 1")
	public BodypartDict findByName(String name);
	
	/**
 	*获取所有字典 身体部位
 	*/
	@Select("select id,name,seq from dict_bodypart where (parent_id is null or parent_id = 0) "
			+ " and  in_used = 1 order by seq asc")
	public List<BodypartDictRes> findAll();
	
	/**
	 * 获取子疾病列表
	 * @param parentId
	 * @return
	 */
	@Select("select id,name,seq from dict_bodypart where parent_id = #{parentId}"
			+ " and  in_used = 1 order by seq asc")
	public List<BodypartDictRes> findBodypartByParentId(Integer parentId);
	
	@Select("select id,name,seq from dict_bodypart where "
			+ "  in_used = 1 order by seq asc")
	public List<BodypartDictRes> findAllNotParam();
	
	@Select("select b.name,b.id from r_symptom_relation a,t_symptom b where a.relation_id = b.id and "
			+ " a.symptom_id = #{sysptomId}")
	public List<SymptomRes> findSysptomRelation(Integer sysptomId);
	

}	